<?php

/**
 * network actions.
 *
 * @package    seth
 * @subpackage network
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class networkActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
      $this->netDevs = $this->getRoute()->getObjects();
  }

  public function executeShow(sfWebRequest $request)
  {
    $this->net_dev = $this->getRoute()->getObject();
  }

  public function executeNew(sfWebRequest $request)
  {
    $this->form = new NetDevForm();
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->form = new NetDevForm();
    $this->processForm($request, $this->form);
    $this->setTemplate('new');
  }

  public function executeEdit(sfWebRequest $request)
  {
    $this->form = new NetDevForm($this->getRoute()->getObject());
  }

  public function executeUpdate(sfWebRequest $request)
  {
    $this->form = new NetDevForm($this->getRoute()->getObject());

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->getRoute()->getObject()->delete();

    $this->redirect('network/index');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    
    if ($form->isValid())
    {
      $net_dev = $form->save();
      $this->redirect('network/edit?id='.$net_dev->getId());
    }
  }
  
  private function checkNetDev($option=array()){
      
      if (isset($option["type"]))
          $type=$option["type"];
      else
          $type="Osiride";
   
  }
}
